const App = {
    mixins: [Query],//配置文件，路径/utils/mixins.js
    data() {
        return {
            page: {
                activeName: 'first',
                value1: '',
                value2: '',
                PageNumber: 1, //页码
                RowAmount: 10,
                Condition: window.btoa(unescape(encodeURIComponent("%%")))
            },
            form: {},
            form1: {},
            str1: '',
            personal_points_account: [],//积分账户
            showDialog1: false,
            AttachmentData: [],//查看附件
            fileUrl: '',
            showDialog2: false
        }
    },
    mounted() {

    },
    computed: {
        isStatus() {
            return function (row) {
                if (row.Row_Status == '2') {
                    return { label: '未发布', value: 'primary', color: '#409EFF' };
                } else if (+new Date(row.Start_DateTime) > +new Date()) {
                    return { label: '已发布', value: 'success' , color: '#67C23A'};
                } else if (+new Date(row.Start_DateTime) < +new Date() && +new Date(row.End_DateTime) > +new Date()) {
                    return { label: '进行中', value: 'warning', color: '#E6A23C' };
                } else if (+new Date(row.End_DateTime) < +new Date()) {
                    return { label: '已结束', value: 'info', color: '#909399' }
                } else {
                    return { label: '', value: '', color: ''}
                }
            }
        }
    },
    methods: {
        handleClick() {
            if (this.page.activeName == 'first') {
                this.str1 = '';
            } else if (this.page.activeName == 'second') {
                this.str1 = "\r\nAND questionnaire.Row_Status = '2'";
            } else if (this.page.activeName == 'third') {
                this.str1 = "\r\nAND questionnaire.Row_Status = '0' AND questionnaire.Start_DateTime > NOW()";
            } else if (this.page.activeName == 'fourth') {
                this.str1 = "\r\nAND questionnaire.Row_Status = '0' AND NOW() BETWEEN questionnaire.Start_DateTime AND questionnaire.End_DateTime";
            } else if (this.page.activeName == 'fifth') {
                this.str1 = "\r\nAND questionnaire.Row_Status = '0' AND questionnaire.End_DateTime < NOW()";
            }
            this.page.ExtensionCondition = window.btoa(unescape(encodeURIComponent(this.str1)));
            this.postgetList(this.page)
        },
        check() {
            this.page.Condition = window.btoa(unescape(encodeURIComponent("%" + this.page.value1 + "%,%" + this.page.value2 + "%")));
            this.postgetList(this.page)
        },
        //树的点击筛选事件
        handleNodeClick(data, node) {

        },
        handle2(row){
            this.$confirm('是否'+ (row.Row_Status == '2'?'发布':'取消发布')+'该调查问卷', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => {
                let { TableName, primary_key } = JSON.parse(document.getElementById("table").getAttribute("data-options"));
                $.ajax({
                    headers: requestHeaders(),
                    url: `${mh}/generalBusiness/generalQueryByTableNameWithOriginal`,
                    method: "post",
                    data: {
                        Data: TableName,
                        Condition: primary_key + "='" + row[primary_key] + "'"
                    },
                    success: (res) => {
                        if (res.length == 1) {
                            res[0].Row_Status = (row.Row_Status=='0'?'2':'0');
                            let lJSONObject_DataSet = new Object();
                            let lJSONObject_Table = new Object();
                            lJSONObject_Table[TableName] = res;
                            lJSONObject_DataSet['Modify'] = lJSONObject_Table;
                            let Operation_Main = JSON.stringify(deepClone(lJSONObject_DataSet));
                            if (!lJSONObject_DataSet['Add']) {
                                lJSONObject_DataSet['Add'] = new Object();
                            }
                            lJSONObject_DataSet['Add']['base_operation_log'] = [{
                                Operation_Type: '0',
                                Operation_Path: this.relativePath,
                                Operation_Main,
                                Operation_Interface: "generalSave",
                                Operation_IP: getIpAddress()
                            }]
                            submitSave(lJSONObject_DataSet,(res)=>{
                                if (res.Status == 'success') {
                                    this.postgetList(this.page);
                                } else {
                                    this.$message({
                                        type: 'error',
                                        message: '操作失败'
                                    });
                                }
                            })
                        } else {
                            this.$message({
                                type: 'error',
                                message: '操作失败'
                            });
                        }

                    },complete: (XMLHttpRequest) => {
                 
                        requestPretreatment(XMLHttpRequest);
                    }
                });
            }).catch(() => { });
        },
    },
};

const { createApp } = Vue;
const app = createApp(App);
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.component('yl-upload', ylUpload);
app.component('yl-online-preview', ylOnlinePreview);
app.use(ElementPlus, { locale: zhCn });
app.mount("#app");
